package com.fieldchain.ex.fa100.utils.chart.utils.zb;

import com.fieldchain.ex.fa100.bean.kline.KLineBean;
import com.fieldchain.ex.fa100.utils.chart.dataset.MyBarDataSet;
import com.fieldchain.ex.fa100.utils.chart.dataset.MyBarEntry;
import com.github.mikephil.charting.data.BarData;
import com.github.mikephil.charting.data.BarEntry;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by biyunlong
 * Email: 1225198434@qq.com
 * Data:  2018/10/16
 */
public class ZbDataParse {
    public static ArrayList<KLineBean> getKlineList(List<List<String>> list) {
        ArrayList<KLineBean> datas = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            List<String> data = list.get(i);
            int time = i;
            float high = Float.parseFloat(data.get(1));
            float open = Float.parseFloat(data.get(2));
            float low = Float.parseFloat(data.get(3));
            float close = Float.parseFloat(data.get(4));
            float vom = Float.parseFloat(data.get(5));
            KLineBean kLineBean = new KLineBean(time, high, open, low, close, vom);
            datas.add(kLineBean);
        }

        return datas;
    }


    public BarData getEptData(int size){
        BarData barData=new BarData();
        MyBarDataSet set=new MyBarDataSet(getMyEpt(size),getEpt(size),"");
        barData.addDataSet(set);
        return barData;
    }

    public List<MyBarEntry> getMyEpt(int size) {
        List<MyBarEntry> mlbar = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            MyBarEntry entry = new MyBarEntry(i, 0);
            mlbar.add(entry);
        }
        return mlbar;
    }
    public List<BarEntry> getEpt(int size) {
        List<BarEntry> mlbar = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            BarEntry entry = new BarEntry(i, 0);
            mlbar.add(entry);
        }
        return mlbar;
    }
}
